//
//  ParserTest.m
//  CEDict
//
//  Created by Eric Nadeau on 07-06-02.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "ParserTest.h"


@implementation ParserTest

-(void) testParser
{
	NSString* line = [NSString stringWithCString: "你好 你好 [ni3 hao3] /hello/how are you/"];
	NSString* simplified = [NSString stringWithCString: "你好"];
	NSString* traditional = [NSString stringWithCString: "你好"];
	NSString* pinyin = @"ni3 hao3";
	NSString* def1 = @"hello";
	NSString* def2 = @"how are you";
	
	Entry* word = [Parser parseLine:line];

	STAssertTrue( [simplified isEqualTo: [word simplified]], @"Verifying simplified characters." );
	STAssertTrue( [traditional isEqualTo: [word traditional]], @"Verifying traditional characters." );
	STAssertTrue( [pinyin isEqualTo: [word pinyin]], @"Verifying pinyin." );
	
	STAssertTrue(
		(2 == [[word english] count])
		&&
		(
			(
				[def1 isEqualTo: [[word english] objectAtIndex:0]]
				&&
				[def2 isEqualTo: [[word english] objectAtIndex:1]]
			)
			||
			(
				[def1 isEqualTo: [[word english] objectAtIndex:1]]
				&&
				[def2 isEqualTo: [[word english] objectAtIndex:0]]
			)
		),
		@"Verifying english definitions."
	);
}

@end
